home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Lattice C v5.02 d5.adf / addendum.doc next >
Text File  |  1988-11-07  |  60KB  |  1,479 lines

  1. This file contains omissions/corrections which will be incorporated
  2. into the version 5.0 documentation at a later date.
  3. ===================================================================
  4.  
  5. TABLE OF CONTENTS
  6.  
  7. (1)  Assembly Language Topics
  8.     -- Version 5.0 Enhancements
  9.     -- Writing Assembly Language Modules for C
  10.     -- The CSECT Directive
  11.     -- Relative Addressing
  12.  
  13. (2)  Linker Topics
  14.     -- New Features of Blink
  15.     -- Introduction to Overlays
  16.     -- Custom Overlay Managers
  17.  
  18. (3)  Creating Load-and-Stay Resident Programs
  19.  
  20. (4)  Compiler-Defined Preprocessor Symbols
  21.  
  22. (5)  Direct Calling of Amiga Libraries
  23.     -- Coding Library Calls for In-Line Code Generation
  24.  
  25. (6)  Using the FD2PRAGMA Program
  26.  
  27. (7)  Built-In Functions 
  28.  
  29. (8)  Header File Compression 
  30.     -- Header File Organization
  31.  
  32. (9)  Library Documentation Corrections
  33.  
  34. (10) Additional Notes On The Source Level Debugger 
  35.  
  36. (11) New Keywords in 5.0
  37.  
  38. (12) Library Descriptions
  39.  
  40. (13) Description of Binary Patch Program
  41.  
  42. (14) 68881 Notes
  43.  
  44.   
  45. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  46. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  47. ::: 1  ::::::::::::: ASSEMBLY LANGUAGE TOPICS :::::::::::::::::::::::
  48. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  49. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  50.  
  51. The assembler included in this package has many new features. 
  52.  
  53. Addressing Modes.
  54.  
  55.    Listed below are all the addressing modes supported.
  56.  
  57.    Mode            Example                Notes
  58.  
  59.    Dn            add.w  d1,d0
  60.    An            addq.w #1,a1
  61.    (An)            add.w  (a1),d0
  62.    (An)+        add.w  (a1)+,d0
  63.    -(An)        add.w  -(a1),d0
  64.    d16(An)        add.w  10(a1),d0
  65.    d8(An,Xn)        add.w  10(a1,a2.l),d0
  66.    bd(An,Xn)        add.w  $10000(a1,a2.l),d0    68020 only
  67.    ([bd,An],Xn,od)    add.w  ([10,a1],a2.l,20),d0    68020 only
  68.    ([bd,An,Xn],od)    add.w  ([10,a1,a2.l],20),d0    68020 only 
  69.    (xxx).W        add.w  (100).w,d0
  70.    (xxx).L        add.l  (100).l,d0
  71.    #<data>        add.l  #100,d0
  72.    d16(PC)        add.w  10(PC),d0
  73.    d8(PC,Xn)        add.w  10(PC,a2.l),d0
  74.    bd(PC,Xn)        add.w  $10000(PC,a2.l)        68020 only
  75.    ([bd,PC],Xn,od)     add.w  ([10,PC],a2.l,20),d0    68020 only
  76.    ([bd,PC,Xn],od)     add.w  ([10,PC,a2.l],20),d0    68020 only
  77.    
  78.    where
  79.        d8 is an eight bit number
  80.        d16 is a sixteen bit number
  81.        bd is a 32 bit byte displacement
  82.        od is the 32 bit outer displacement
  83.        An is an address register (a0-a7)
  84.        Dn is a data register (d0-d7)
  85.        Xn is an index register (a0.w-a7.l)
  86.     
  87.    Note:
  88.        All the operands on the addressing modes marked 68020 are
  89.        optional.
  90.        
  91. Data Formats.
  92.  
  93.     New data formats are allowed for 68881 floating point instruction. 
  94. These include:
  95.  
  96.     #2.1
  97.     #2.1E+10
  98.  
  99.     These will be converted into the proper floating point formats 
  100. according to the type of instruction. For example, in the following 
  101. instruction:
  102.  
  103.     fmove.s    #2.1,fp1
  104.  
  105. 2.1 will be in single precsion.
  106.  
  107.     Other sizes allowed are:
  108.  
  109.     fmove.d #2.1,fp1        double precision
  110.     fmove.x #2.1,fp1        extended precision
  111.  
  112.     Note that the packed data format is not converted for you.
  113. Also if you want to specify the bit pattern by hand you can use the
  114. following formats:
  115.  
  116.     fmove.d    #$12345678,fp1            32 bit pattern
  117.     fmove.s    #$123456781234568,fp1        64 bit pattern
  118.     fmove.x    #$123456781234567812345678,fp1    96 bit pattern
  119.     
  120.     You can also specify the constants in octal (ie @123456712) or 
  121. binary (ie %0110110100110101).
  122.  
  123. Opcodes.
  124.  
  125.     All the 68020 opcodes have been added. A new size for all the branch
  126. instructions has been added. The size fields allowed on branches are
  127. demostrated below.
  128.  
  129.     BSR.S or BSR.B        generate 8 bit offsets
  130.     BSR.W            generates 16 bit offsets
  131.     BSR.L            generates 32 bit offsets (Note that
  132.                 this is only supported on the 68020
  133.                 and that BSR.L to externs are not
  134.                 allowed.)
  135.     BSR            with no size will calculate the size
  136.                 needed, 16 bit for externs.
  137.  *NOTE that this is different from the way the previous version of
  138.        the assembler worked. For example, the old assembler would 
  139.        make the instruction
  140.                BRA.L  FOO 
  141.        a 16 bit branch. This version makes a 32 bit branch which is
  142.        only supported on the 68020.
  143.  
  144.  
  145. ___________________________________________________________________
  146. -------------------------------------------------------------------
  147.  
  148.  
  149. WRITING ASSEMBLY LANGUAGE MODULES FOR C
  150.  
  151. You can write assembly language modules for inclusion in C programs
  152. if you are sufficiently experienced with the 68000 instruction set
  153. and if you observe the following:
  154.  
  155. 1. The statements defining the functions should be placed in the
  156.    text section by preceding them with:
  157.  
  158.              CSECT     text
  159.  
  160.    This is not an absolute requirement, since the functions will be
  161.    accessible regardless of the section in which they are defined,
  162.    but it assures them of placement with the C functions during
  163.    linking (if the -s option is used). Each function entry must be
  164.    declared in an XDEF statement:
  165.  
  166.                 XDEF     AFUNC
  167.                  .
  168.                  .
  169.                  .
  170.         FUNC    EQU        *
  171.  
  172. 2. If the module is to define data locations to be accessed (using
  173.    extern declarations) in C modules, those definitions should be
  174.    placed in the data section by preceding them with:
  175.  
  176.        CSECT   data
  177.  
  178.    Each data element must be declared in an XDEF statement in order
  179.    to be accessible in the C modules:
  180.  
  181.                 XDEF     D0,D1,D2
  182.         D0      DC.L     $4000
  183.         D1      DC.W     $8000
  184.         D2      DC.L     D0
  185.  
  186. 3. Any of the registers D2-D7 or A2-A6 must be preserved by the
  187.    module, and the return value loaded into the appropriate data
  188.    registers.
  189.  
  190.    To call a C function from an assembly language module, you must
  191.    include an XREF declaration for the function. Before calling the
  192.    function (via JSR), you must supply any expected arguments in the
  193.    proper order. After control returns from the called function, the
  194.    stack pointer must be adjusted to account for pushed arguments.
  195.  
  196.           XREF      cfunc
  197.           MOVE.L    DO,-(A7)     ;push argument
  198.           MOVE.L    D1,-(A7)
  199.           JSR       cfunc        ;call function
  200.           ADDQ      #8,A7        ;restore stack ptr
  201.  
  202.    Data elements defined in a C module may be accessed via XREF
  203.    statements, as well:
  204.  
  205.             XREF      XD2,XD3
  206.              .
  207.              .
  208.              .
  209.             MOVE.L    XD2,D0
  210.  
  211.  
  212. ___________________________________________________________________
  213. -------------------------------------------------------------------
  214.  
  215. THE CSECT DIRECTIVE
  216.  
  217. All of the standard 68000 instructions are supported, as described
  218. in the Motorola manual.  Assembly directives are discussed in the
  219. following paragraphs.
  220.  
  221. Instead of the section directive, the Lattice assembler uses the
  222. CSECT directive of the form:
  223.  
  224.          CSECT     name
  225.  
  226. where name is the control section name.  Note that a CSECT directive
  227. must precede any data-defining statements (i.e., there is no default
  228. control section).  The Lattice 68000 macro assembler uses the concept
  229. of named control section to control the location of data and text
  230. during linking; the CSECT directive defines the start of a
  231. relocatable control section of the specified name.  Note that "text"
  232. and "data" are used for compatibility with object files generated by
  233. the C compiler.  Only one instance of a CSECT directive with a
  234. particular name is permitted; that is, scattered definitions of data
  235. for a CSECT are not allowed.
  236.  
  237. The CSECT directive may be used to specify additional information
  238. about the control section; its general format is:
  239.  
  240.          CSECT   name,type,align,rtype,rsize
  241.  
  242. Only the name parameter must be present; it specifies the name of
  243. the control section.  type is zero for code sections, one for data
  244. sections, and 2 for uninitialized data sections (like the udata
  245. section used by the C compiler); the default value is zero (code).
  246. align specifies the alignment requirements of the control section
  247. as a power of two; thus, align equal to one means the section will
  248. begin on an even address, and a value of two means an address
  249. divisible by 4, etc.  This parameter is non-functional on the Amiga.
  250. All sections are long-word aligned.
  251.  
  252. The last two parameters specify the type and size of relocation
  253. information associated with the address of any data in the control
  254. section.  rtype specifies the relocation type, which determines the
  255. meaning of the address, or relocation data; the default value is
  256. zero.
  257.  
  258. rsize specifies the size, in bytes, of the relocation data for the
  259. section; the default value is four.  The legal types and sizes of
  260. relocation information on the 68000 are summarized in the following
  261. table:
  262.  
  263.       Type   Size (bytes)       Description
  264.        0      2 or 4       Absolute short or long address
  265.        1      2            PC-relative offset
  266.        2      2            Address-register-relative offset
  267.  
  268. Type 0 relocation results in an absolute address, while type 1
  269. relocation is computed as the difference between the referenced
  270. address and the location of the reference.  Type 2 relocation is
  271. used to assign offsets for address-register-relative addressing of
  272. data.  Both the base section used for such addressing and any bias
  273. placed in the address register are used when a load module is
  274. constructed.
  275.  
  276. Note that symbols declared in XREF statements within a control
  277. section will be addressed using the relocation type and size
  278. defined for that section.  The use of CSECT directives which are
  279. compatible with the -b and -r options of the C compiler are
  280. described later.
  281.  
  282. ___________________________________________________________________
  283. -------------------------------------------------------------------
  284.  
  285. RELATIVE ADDRESSING
  286.  
  287. The Lattice assembler can be used to generate assembly language
  288. modules which are compatible with the conventions used in C programs
  289. compiled with the -b option on lc1 or the -r option on lc2.  PC-
  290. relative external function calls can be forced using sequences such
  291. as the following:
  292.  
  293.           CSECT   TEXT,0,,1,2
  294.            XREF   cfunc
  295.            XDEF   afunc
  296.    afunc   JSR    cfunc(PC)
  297.            RTS
  298.  
  299. This mechanism is the same as that used for function calls in code
  300. compiled with the -r option on lc2.  Note that the XREF statement
  301. for the external function being called must appear after the CSECT
  302. statement, and that all calls must be made in the PC-relative
  303. addressing mode.  If the XREF statement for the external function
  304. precedes the CSECT statement a standard JSR to a four-byte external
  305. address can be used.
  306.  
  307. Address-register-relative addressing of data can be forced if the
  308. data is placed in a control section such as the following:
  309.  
  310.              CSECT   data,1,,2,2
  311.              XREF    xdata
  312.     data1    DC.W    10
  313.     data2    DC.L    20
  314.  
  315. It then must be addressed using the appropriate address register:
  316.  
  317.      MOVE.W    data1(A5),DO
  318.      MOVE.L    data2(A5),D1
  319.      MOVE.L    d1,xdata(A5)
  320.  
  321. this mechanism is the same as that used for addressing data in
  322. code compiled with the -b option on lc1.  Note that the XREF
  323. statement for any external data elements being addressed must appear
  324. after the CSECT statement, and that all data references must be made
  325. in the address-register-indirect-with-displacement addressing mode.
  326. If the XREF statement for the external data precedes the CSECT
  327. statement, a standard reference to a four-byte external address can
  328. be used.
  329.  
  330.  
  331. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  332. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  333. ::: 2  ::::::::::::::::::: LINKER TOPICS ::::::::::::::::::::::::::::
  334. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  335. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  336.  
  337.  
  338. NEW FEATURES OF BLINK
  339.  
  340. 1. Strip Debugging Information with Blink
  341.  
  342.    Blink will allow the stripping of debugging information given an
  343.    executable that contains debugging info. To do this type:
  344.  
  345.           blink oldfile TO newfile NODEBUG
  346.  
  347.    where oldfile is an executable file that contains debugging
  348.    information, and newfile is a new executable file that will be
  349.    stripped of debugging information.
  350.  
  351. 2. Generate Programs that can be made Resident
  352.  
  353.    To generate an executable file that can be made resident simply 
  354.    link with the startup file CRES.O, CATCHRES.O, or CATCHRESNR.O
  355.    instead of the normal startup file C.O. The executable file 
  356.    will have the PURE bit set. There are some rules that must be 
  357.    followed when doing this.
  358.  
  359.      -- Never use -b0 when compiling the file.
  360.      -- All data hunks must be mergeable.
  361.      -- There should be no absolute references to data.
  362.      -- Use #pragmas instead of AMIGA.LIB when possible.
  363.  
  364.    In some cases it may be necessary to link with AMIGA.LIB. This is
  365.    ok as long as BLINK doesn't generate any warning about references to 
  366.    absolute symbols.
  367.  
  368.    The following diagram describes how resident programs run.
  369.  
  370.       An old executable looks        When running resident
  371.       like this:                     programs:
  372.  
  373.       |--------------------|         |---------------------|
  374.       |                    |         |                     |
  375.       |        CODE        |         |        CODE         |
  376.       |                    |         |                     |
  377.       |--------------------|         |---------------------|
  378.       |                    |         |                     |
  379.       |     MERGED DATA    |         |      MERGED DATA    |
  380.       |                    |         | (used only during   |
  381.       |--------------------|         |       load )        |
  382.       |     MERGED BSS     |         |---------------------|
  383.       |--------------------|                   .
  384.                                                .
  385.                                                .
  386.                                      |----------------------|
  387.                                      | Segmented Allocated  |
  388.                                      | by cres.o and used   |
  389.                                      | by running program   |
  390.                                      | Referenced off of A4 |
  391.                                      |                      |
  392.                                      |----------------------|
  393.  
  394.    Each time the program is run a new data segment is created, old
  395.    data is copied into it, and relocations are performed inside it.
  396.    When the program terminates, the segment is released.
  397.  
  398.    The special symbols that blink creates are as follows:
  399.  
  400.       _LinkerDB   pointer to data section
  401.       RESOFF      offset that LinkerDB is in data (0 or 0x8000)
  402.       RESLEN      number of longwords in data
  403.       NEWDATAL    number of bytes in new data segment including BSS
  404.  
  405.    The number of relocs in the data segment is stored just after the data
  406.    segment, with the relocs following this.
  407.  
  408. ___________________________________________________________________
  409. -------------------------------------------------------------------
  410.  
  411. INTRODUCTION TO OVERLAYS
  412.  
  413. Overlays are code groups and data hunk groups which reside in main
  414. memory only while in use. When one loaded group is no longer needed
  415. and another is needed, the memory used by the old group is reclaimed,
  416. and may be used to load in the new group. This group loading and
  417. unloading is performed automatically.
  418.  
  419. Overlays on the Amiga are organized as a tree structure with nodes.
  420. Each node consists of a group of code hunks and data hunks.  The tree
  421. consists of a ROOT NODE, which is permanently resident, and one or
  422. more OVERLAY NODES.  The root node usually contains the libraries,
  423. your main program, and extensively used subroutines, etc.  The
  424. overlay nodes consist of hunks which are to be loaded only as needed
  425. to conserve memory space.
  426.  
  427.        Figure 1:  Overlay Tree
  428.  
  429.                   Root
  430.                    |
  431.           -------------------
  432.        overlay1           overlay2
  433.                              |
  434.                    --------------------
  435.                 overlay3           overlay4
  436.                    |
  437.                 overlay5
  438.  
  439. In the overlay tree in Figure 1, overlay nodes 1 and 2 execute
  440. independently, using the same memory, one at a time.  Also, if
  441. overlay node 2 is loaded, it can then load either of nodes 3 and 4,
  442. which share a block of memory in which they can execute.  Thus, if
  443. 3 is loaded and executing, 4 and 1 are NOT loaded, overlay node
  444. 2 is loaded, and overlay 5 may be loaded. If overlay node 1
  445. is loaded and executing, then nodes 2 through 5 are NOT currently in
  446. memory.
  447.  
  448. Your overlay tree need not be a binary tree, balanced, or of a depth
  449. greater than 1.  You can have 50 overlay nodes, all hanging from the
  450. root node. The nodes may be all mutually exclusive and independent
  451. of each other, or one long chain of overlay nodes. You must decide
  452. which of your routines can operate independently of each other.
  453.  
  454. Overlays are not a general-purpose mechanism. They are intended
  455. primarily for large applications (100k or more), which must run in a
  456. small amount of memory in order to leave more room for data. Such
  457. applications should also have a great deal of modularity, with a
  458. definite calling hierarchy among the code routines.
  459.  
  460. One good example (except for size) is a linker. Although it does
  461. not use overlays, it is feasible for blink to have overlays. If you
  462. run blink with the VERBOSE option, you see messages about
  463. "Parsing, Pass1," and so on. These represent clear phases of linking
  464. that are independent of each other--the only continuity is in the
  465. internal data structures they create and manipulate.
  466.  
  467. To maximize available memory, either for the linker's data structures
  468. or for other concurrent programs and their data, blink could have
  469. been linked to use overlays, allowing no more than about 5k to 10k
  470. resident in memory at any given moment. The sole overhead would be a
  471. slight drop in speed performance due to the individual loading of the
  472. separate overlay nodes.  Fortunately, since blink is relatively small
  473. and efficient in memory usage, it does not use overlays.
  474.  
  475.  
  476. 1. The Overlay Manager
  477.  
  478.    Overlays depend on the overlay manager. Every time a routine in
  479.    an overlay node is referenced, a call is made to the Overlay
  480.    Manager, which then scatter loads the desired overlay node,
  481.    unloading any existing nodes which exist on another, mutually
  482.    exclusive branch of the tree. These calls to the Overlay Manager
  483.    are done by blink automatically and are effectively invisible to
  484.    your own code.
  485.  
  486.    The Overlay Manager can be put into the libraries rather than
  487.    kept as a separate file, as under ALINK. You can also override
  488.    the original Overlay Manager with one of your own, thanks to an
  489.    extension in blink.  (See Custom Overlay Managers later in this
  490.    text for more information on this.)
  491.  
  492. 2. Using Overlays
  493.  
  494.    When using overlays, you should design your overlay tree after
  495.    you have an idea of the calling hierarchy of your application.
  496.    Those routines which are called frequently, or which are called
  497.    by almost every other routine in your application, should be
  498.    placed in the root node. Generally, the more commonly accessed
  499.    the routine, the closer to the root node it should be.  Major
  500.    independent routines however, should be placed in nodes which
  501.    are more in accordance with the general calling hierarchy.
  502.  
  503.    If you do not come up with an efficient tree, your program will
  504.    merely be a little unorganized; an incorrect tree will result in
  505.    a blink warning message.
  506.  
  507.  --------------------------------------------------------------------
  508.  | REMEMBER: Always put your main program into the root node (using |
  509.  | either FROM or ROOT).  Putting the main program in an overlay    |
  510.  | node will not work.                                              |
  511.  --------------------------------------------------------------------
  512.  
  513. 3. Overlay Node Restrictions
  514.  
  515.    There are restrictions when referencing routines across overlay
  516.    nodes as illustrated in Figure 2.
  517.  
  518.          Figure 2:  Overlay Tree Example
  519.  
  520.                       Root
  521.                     (a, b, c)
  522.                         |
  523.               --------------------
  524.            overlay1           overlay2
  525.             (d, e)             (f, g)
  526.                                  |
  527.                        --------------------
  528.                     overlay3           overlay4
  529.                       (h)                (i)
  530.                        |
  531.                     overlay
  532.                       (j)
  533.  
  534.  
  535.     -- Any of the overlay routines (d, e, f, g, h, i, j) can
  536.        call any of the root node routines (a, b, c).
  537.  
  538.    -- Any of the root node routines (a, b, c) can call
  539.       any of the first overlay level routines (d, e, f, g).
  540.  
  541.    -- Routines d and e can call each other and any root node
  542.       routines.
  543.  
  544.    -- Routines f and g may call each other, any of the root
  545.       node routines, or routines h and i.
  546.  
  547.    -- Routines h may call routines f, g, j, or any of the root
  548.       node routines.
  549.  
  550.    -- Routines i may call routines f and g, or any of the root
  551.       node routines.
  552.  
  553.    -- Routine j may call routines a, b, c, f, g, and h and only
  554.       those routines.
  555.  
  556. 4. WITH Files
  557.  
  558.    Similar to ALINK, blink uses WITH files to inform the linker that
  559.    you want overlays--the syntax is the same as for ALINK.  After
  560.    the keyword OVERLAY, you should list the file or files of your
  561.    node or nodes. Use one line per node with as many files as you
  562.    want per node.  For line continuation, use an asterisk * at the
  563.    end of the line which continues on the next line.  The nodes
  564.    (i.e. file name groups) should be listed in pre-order fashion.
  565.  
  566.    One other factor you should understand about the syntax is
  567.    asterisks (*). In addition to acting as a continuation symbol at
  568.    the end of a continued WITH line of file overlays, they are also
  569.    used at the beginning of a new line IF THE DEPTH OF THE NODE
  570.    BEING LISTED IS GREATER THAN A NUMERIC VALUE OF ONE.
  571.  
  572.    As an example, the tree described in Figure 1 would look like this
  573.    in WITH file syntax:
  574.  
  575.     OVERLAY overlay1  overlay2  *overlay3  **overlay5  *overlay4
  576.  
  577.    Note the `#'-- this terminates the list as does an End-Of-File.
  578.    Also note that since overlays 1 and 2 are at depth 1, they have
  579.    no asterisks. The depth of a node is specified by the number of
  580.    asterisks.  The depth of an overlay in the tree should be equal
  581.    to the number of asterisks plus one.
  582.  
  583. 5. The MAP File
  584.  
  585.    When overlays are used, appropriate sections of the map file will
  586.    include the information generated by the overlay nodes.  Overlay
  587.    references and symbols will appear in the map file sections to
  588.    which they apply.
  589.  
  590.    The map file sections specific to overlays is obtained using the
  591.    O option to the MAP keyword. This generates a section very much
  592.    like the hunk section provided by the H option.  The O option has
  593.    two additional fields which give the overlay level and overlay
  594.    ordinate of the overlay node to which the code and data hunks
  595.    belong.
  596.  
  597.    If you use the O option but have no overlays, nothing is produced.
  598.  
  599. ___________________________________________________________________
  600. -------------------------------------------------------------------
  601.  
  602.  
  603. CUSTOM OVERLAY MANAGERS
  604.  
  605. You can write your own overlay manager if you need one.  A cycle of
  606. compile (or more likely, assemble) accomplishes this task.  Include
  607. it with the command:
  608.  
  609.          OVLYMGR file
  610.  
  611. The object file must contain the symbol _ovlyMgr. This is exactly
  612. how the symbol must appear in the object file; the character case is
  613. important. You may need to omit the leading underscore, since Lattice
  614. C and the assembler both put it in for you. The code hunk must also
  615. have a section name of NTRYHUNK.
  616.  
  617. Where it is necessary to have a code hunk which absolutely MUST be
  618. the very first hunk in the file, no matter what the linker tries to
  619. do, you should use the section name NTRYHUNK.  blink always forces
  620. the section named NTRYHUNK to be the first hunk. However, this hunk
  621. is never merged with any other hunk, and there can only be one such
  622. hunk. Also, use of this section name for your own code segment will
  623. mean that you CANNOT use overlays (unless the segment is your own
  624. overlay manager), but you should try to avoid using this. You do
  625. not have to use OVLYMGR to use the section name NTRYHUNK--just list
  626. it as another object file.
  627.  
  628. Note that the first hunk is also the program entry point.
  629.  
  630. For further information about writing your own custom overlay
  631. manager, examine hunk 0 of a program which uses overlays. It
  632. does exactly what is necessary to do the overlays and to handle
  633. the entry point problem.
  634.  
  635.  
  636. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  637. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  638. :: 3  ::::: CREATING LOAD-AND-STAY RESIDENT PROGRAMS ::::::::::::::::
  639. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  640. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  641.  
  642. This version of the compiler provides an alternative startup module
  643. named CBack.o which allows you to create Load-and-Stay-Resident (LSR)
  644. code. We strongly recommend that you use CBack.o for ANY program
  645. that:
  646.  
  647.      -- has no requirement for the original CLI window for the
  648.         purposes of output, OR
  649.  
  650.      -- needs to be memory resident (such as POPCLI or MEMWATCH).
  651.  
  652. The design specification of CBack.o means that the programmer only
  653. has to make minimal amendments to existing code in order to take
  654. advantage of LSR code.
  655.  
  656. Linking with CBack.o requires the addition of some definitions to
  657. your main module and an awareness of the setting up which CBack.o
  658. carries out.  The first step is the addition of some global
  659. variables necessary for CBack.o to determine how your task will run:
  660.  
  661.      LONG _stack            Stack space for the created task
  662.      CHAR *_procname        Name of the process to be created
  663.      LONG _priority         The priority to create the process at
  664.      LONG _BackGroundIO     The flag to indicate an I/O requirement
  665.  
  666. Most LSR programs will probably only need a stack size of 4000 bytes
  667. (the system default), although this figure of 4000 may need to be
  668. experimented with depending on the LSR application. There are no
  669. restrictions related to the name, although common sense dictates
  670. that a name which is easily recalled is probably best. The task
  671. priority should be set to 0, once more a baseline figure which may
  672. need to be varied. The _BackGroundIO flag is special flag required
  673. when you wish to perform any type of I/O to the originating console.
  674. When this flag is initialized to 0, your code is expected to carry
  675. out its own I/O to a separate window--or no I/O as the case may be.
  676. The latter is also true for any program which opens its own window.
  677.  
  678. The initializing of _BackGroundIO to a value other than 0 informs
  679. CBack to open the default console and pass it to you in the global
  680. variable _Backstdout. It's the programmer's responsibility to close
  681. this file.
  682.  
  683. -----------------------------------------------------------------
  684. | WARNING: Failure to close this file means that the original   |
  685. | window from which the program was run will NEVER CLOSE. Also, |
  686. | until you close the file handle, the window will remain open. |
  687. -----------------------------------------------------------------
  688.  
  689. While this may be useful for printing out logon banners, diagnostic
  690. messages or results of commands, a window which cannot be closed
  691. under any circumstances other than a system reboot is indicative of
  692. a low standard of programming.
  693.  
  694. _Backstdout is an AmigaDOS file handle and consequently all I/O to
  695. this file handle must be performed with the Write() function--NOT
  696. the Lattice functions of write or fprintf. Closure must be only be
  697. done with Close(). Where a program establishes a resident task to
  698. communicate with, the file handle should be passed to this task for
  699. it to print messages on the CLI window.
  700.  
  701. When the _Backstdout file handle is described as a NULL, your
  702. program cannot perform any output to the window. This can occur when
  703. the program was invoked from the Workbench environment or from
  704. another program which did not have a standard output window available
  705. at the time.
  706.  
  707. The following example demonstrates a do-nothing program which uses
  708. CBack to install itself:
  709.  
  710. #include <exec/types.h>
  711. #include <libraries/dos.h>
  712. #include <proto/dos.h>
  713. #include <string.h>
  714.  
  715. long _stack = 4000;             /* a reasonable amount of stack space */
  716. char *_procname = "my_program";
  717. long _priority = 0;             /* run at standard priority */
  718. long _BackGroundIO = 1;         /* perform background I/O */
  719. extern BPTR _Backstdout;        /* file handle we will write to with */
  720.  
  721. #define MSG "Hello World!"
  722.  
  723. void main(argc, argv)
  724. int argc;
  725. char *argv[];
  726.  
  727. {
  728.    if (argc  == 0)              /* called from Workbench, can't do anything */
  729.         _exit(0L);
  730.  
  731.    if (_Backstdout)             /* called from CLI - print out the string */
  732.      {
  733.      Write(_Backstdout, MSG, strlen(MSG));
  734.      Close(_Backstdout);
  735.      }
  736. }
  737.  
  738. Where an LSR program operates as a single task for the entire system
  739. (such as POPCLI or MEMWATCH, it should check for the existence of a
  740. global message port. If a global message port does not exist, then
  741. the LSR program should create one. After creation of the port, any
  742. control information should be directed through this port. Where a
  743. global message port already exists then this should serve as the
  744. primary port for control information. The sample code for POPCLI
  745. and MEMWATCH demonstrate how this can be achieved.
  746.  
  747. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  748. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  749. :: 4  ::::::: COMPILER-DEFINED PREPROCESSOR SYMBOLS :::::::::::::::::
  750. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  751. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  752.  
  753. The Lattice AmigaDOS Compiler by default assigns the following preprocessor
  754. symbols:
  755.  
  756.         M68000 = 1
  757.         AMIGA = 1
  758.         LATTICE = 1
  759.         LATTICE_50 = 1
  760.  
  761. Using these compiler options will define the following preprocessor
  762. symbols:
  763.  
  764.       Option    Preprocessor symbol
  765.         -d         DEBUG = 1
  766.         -w         SPTR = 1
  767.         w/o -w     LPTR = 1
  768.  
  769.  
  770. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  771. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  772. :: 5  ::::::::: DIRECT CALLING OF AMIGA LIBRARIES :::::::::::::::::::
  773. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  774. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  775.  
  776. In general, the bulk of an Amiga C program will consist of various
  777. library calls. Improvements to this version of the compiler mean that
  778. library routines do not have to go through the stub routines in
  779. amiga.lib, although the option remains for those who wish to still do
  780. this. This gives the advantage of suppressing the code to push the
  781. function parameters on to the stack, calling the stub routine which
  782. places them into the appropriate register and then calls the library.
  783. The compiler can be informed which registers to place the parameters
  784. into and this allows it to select the optimal method of register
  785. loading.
  786.  
  787. There are two advantages to avoiding the use of the amiga.lib stub
  788. routines:
  789.  
  790.     -- Code execution is faster than code using stub routines.
  791.  
  792.     -- Development time is saved by the avoidance of linking.
  793.  
  794. The code generated by this technique does not usually show any
  795. significant saving in size over code generated by the conventional
  796. Amiga.Lib route.  However, the stub routines can account for a large
  797. proportion of a small program and the execution speed advantage can
  798. become important.
  799.  
  800. Calling of these direct functions is done through the inclusion of
  801. the prototype header files. These are located on Compiler Disk #2
  802. with the calling syntax of:
  803.  
  804.     #include <proto/lib-name.h>
  805.  
  806. To use the Open() function of AmigaDOS, the calling sequence would
  807. look like this:
  808.  
  809.       #include <proto/dos.h>
  810.  
  811. ___________________________________________________________________
  812. -------------------------------------------------------------------
  813.  
  814. CODING LIBRARY CALLS FOR IN-LINE CODE GENERATION
  815.  
  816. It should be realized that the techniques used for the library
  817. function calls are not hard coded for the known Amiga functions.
  818. This means that these function calls may be freely used in any
  819. source code, although it is necessary to code a statement of the
  820. form:
  821.  
  822.      #pragma libcall <base> <routine> <offset> <magic>
  823.  
  824. where:
  825.  
  826.      #pragma    part of the special calling routine.
  827.      libcall    part of the special calling routine.
  828.      <base>     the pointer to the library base.
  829.      <routine>  the name of the library routine you intend to
  830.                 directly call.
  831.      <offset>   the offset from the library base of the routine.
  832.      <magic>    the description of the parameters.
  833.  
  834. An example call using the Open() function of AmigaDOS would take
  835. this form:
  836.  
  837.       #pragma libcall DOSBase Open le 2102
  838.  
  839. where:
  840.  
  841.      DOSBASE    the library pointer.
  842.      Open       the name of the function being called.
  843.      le         the offset from the library base as a hexadecimal value.
  844.      2102       the value used by the compiler to determine the register conventions.
  845.  
  846. Note that the offsets from the library base actually have negative
  847. values, this is ignored in the interests of clarity.
  848.  
  849. The calculation of the magic portion is arrived at by breaking down
  850. the number into nibbles representing the register conventions. The
  851. format of the magic number is:
  852.  
  853.          4321r#
  854.  
  855. where the numbers 4, 3, 2, and 1 indicate the registers where the
  856. fourth, third, second and first parameters respectively, are to be
  857. placed. The values to use for these are:
  858.  
  859.              HEX      DATA        HEX      ADDRESS
  860.              VALUE    REGISTER    VALUE    REGISTER
  861.              0        D0          8        A0
  862.              1        D1          9        A1
  863.              2        D2          A        A2
  864.              3        D3          B        A3
  865.              4        D4          C        A4
  866.              5        D5          D        A5
  867.              6        D6          E        A6
  868.              7        D7          F        A7
  869.  
  870. Note that address registers A5 to A7 are never used in the above
  871. context.  Observant programmers may recognize this pattern as that
  872. assigned by Motorola to the registers in the processor instruction
  873. set.
  874.  
  875. The `r' portion of the magic number indicates the register where the
  876. result is returned.  This is usually 0 for data register D0, although
  877. there are no restrictions as to which register you may select for
  878. return values.
  879.  
  880. The `#' value indicates the total number of parameters for passing
  881. to the routine. The high-order bit (0X8) of this nibble indicates
  882. that the routine to be called unreasonably destroys the contents of
  883. data registers D6 and D7. In most cases you may ignore this nibble
  884. completely since it is intended to provide a Kickstart version 1.1
  885. compatibility with the Text() and DoIO() functions.
  886.  
  887. Let's return to our example function call:
  888.  
  889.      #pragma libcall DOSBase Open le 2102
  890.  
  891. Examining the magic and offset values, you will see how these
  892. figures were arrived at by an examination of vol.2 of the Amiga
  893. ROM Kernel Reference Manual page A-122. The synopsis of the Open()
  894. function is:
  895.  
  896.     file = Open( name, accessMode )
  897.     D0           D1       D2
  898.  
  899. Reference to the previous table will show that data registers D2,
  900. D1 and D0 have the values of 2, 1 and 0 respectively, and this forms
  901. the first part of the value 2102.
  902.  
  903. If you examine the function OpenLibrary() on page A-124 in vol.2 of
  904. the Amiga ROM Kernel Manual, the synopsis is:
  905.  
  906.    library = OpenLibrary(libname, version)
  907.     D0                   A1        D0
  908.  
  909. The first part of our magic value would then be 090, the second part
  910. parameter value is 2, thus the final calculated value is 0902.
  911.  
  912. The offset values can be obtained from the v1.2 .fd files on the v1.2
  913. Extras disk. Alternatively, the columns starting on page D-5 of vol.1
  914. of the Amiga ROM Kernel Manual provide these. For our example, the
  915. offset value is shown on page D-6 in exec.lib and has a value of 228.
  916.  
  917. Note that the current edition of vol.1 of the Amiga ROM Kernel Manual
  918. has several errors in the .fd files listing. One of the most readily
  919. identifiable errors shows the incorrect bias for the DOS library --
  920. (add the decimal value 30 or hexadecimal value 1E to correct the
  921. respective columns. There are also several exec.lib functions missing
  922. from the end of the exec.lib listing.  A good policy is to always
  923. check the .fd files on your disks rather than rely solely on the
  924. reference manuals.
  925.  
  926.  
  927. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  928. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  929. :  6  ::::::::::: USING THE FD2PRAGMA PROGRAM :::::::::::::::::::::::
  930. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  931. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  932.  
  933. The format of the #pragma statements for library calls is relatively
  934. easy to understand and code, it is difficult to maintain and or
  935. decode. We have provided a utility which will take a standard
  936. ASCII .fd file and convert this file to the appropriate #pragma
  937. statements.
  938.  
  939. The .fd file should consist of single statements per line and
  940. structured in the following form:
  941.  
  942.    -- A line to be processed as a directive starts with two
  943.       ## (hash) symbols.
  944.  
  945.    -- An asterisk (*) at the start of a line symbolizes a
  946.       comment line.
  947.  
  948.    -- Any other line indicates entry points into the library.
  949.  
  950. The directives for the conversion utility are:
  951.  
  952.     ##base _name   Identifies the global variable pointing to the
  953.                    base of the library.
  954.  
  955.     ##bias n       Identifies the offset value between the library
  956.                    base and the initial vector in the library.
  957.  
  958.     ##public       Identifies subsequent lines as being available
  959.                    to programmers.
  960.  
  961.     ##private      Identifies subsequent lines as being available to
  962.                    the library only.
  963.  
  964.     ##end         Marks the end of the .fd file.
  965.  
  966. The entry points into the library take the form:
  967.  
  968.        entryname(arguments)(registers)
  969.  
  970. with commas separating the individual arguments and registers. The
  971. latter may also be separated by a slash character `/'. Some example
  972. entries look like this:
  973.  
  974.          InitCode(startClass,version)(D0/D1)
  975.          PrintIText(rp,itext,left,top)(A0/A1,D0/D1)
  976.  
  977. The first example is from exec.library while the second example is
  978. from intuition.library -- note the mixing of commas and slashes on
  979. the register descriptions.
  980.  
  981. We strongly suggest that you always maintain and update the .fd
  982. file, running it through the FD2PRAGMA utility rather than trying
  983. amend the #pragmas themselves. This technique is less likely to
  984. lead to errors.
  985.  
  986. Conversion of the .fd file is done by a command line of the
  987. following syntax:
  988.  
  989.         fd2pragma alpha.fd beta.h
  990.  
  991. where:
  992.  
  993.   alpha.fd    the .fd file for conversion.
  994.   beta.h      the new header file after conversion.
  995.  
  996. Any errors encountered in the conversion will be printed on the
  997. standard output file. Typical errors would be invalid directives,
  998. invalid register specifications or no ##end statement.
  999.  
  1000.  
  1001. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1002. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1003. : 7  ::::::::::::::::: BUILT-IN FUNCTIONS :::::::::::::::::::::::::::
  1004. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1005. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1006.  
  1007. This version of the compiler includes several built-in functions
  1008. designed to generate high quality 68000 code. These functions are
  1009. encouraged by the ANSI standard over others which might have
  1010. previously been used. The built-in functions are:
  1011.  
  1012.                strlen       memset
  1013.                strcmp       memcmp
  1014.                strcpy       memcpy
  1015.  
  1016. The compiler will automatically recognize a built-in function provided
  1017. it is prefixed by the string:
  1018.  
  1019.              __builtin_
  1020.  
  1021. The #defines in the header files string.h and stdlib.h have been
  1022.  modified to accomplish the invocation of a built-in function. To
  1023.  take advantage of these functions it is necessary to include the
  1024.  correct header file -- for these functions it is string.h file.
  1025.  In situations where you do not want to use the built-in functions,
  1026.  you can modify the appropriate function with an #undef.
  1027.  
  1028. An additional built-in function has been provided to assist in the
  1029. speedier development of small programs. This is:
  1030.  
  1031.              printf
  1032.  
  1033. When this function is called, the compiler examines the formatting
  1034. string:
  1035.  
  1036.       -- When it is a constant string with no substitutions, the
  1037.          compiler changes the printf call to a _write call.
  1038.  
  1039.       -- When it is a constant string AND only contains %s, %d and
  1040.          %p formats, a call is made to _tinyprintf.
  1041.  
  1042. The purpose behind this is to allow programmers to use printf for
  1043. output without having to write a trimmed version which does not
  1044. handle the unused formats.
  1045.  
  1046. The advantage of built-in functions is related to the ability of the
  1047. compiler to exploit register contents. For example, the strlen call
  1048. will generate no code if the input string is a constant string. In
  1049. addition, functions cannot return the result pointer if it is
  1050. unused -- all of this tends to a regime which produces significantly
  1051. less code than an equivalent call to the library function.
  1052.  
  1053. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1054. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1055. : 8  ::::::::::::: HEADER FILE COMPRESSION ::::::::::::::::::::::::::
  1056. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1057. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1058.  
  1059. The utility lcompact can be used to compress header or source files
  1060. in a form that can be read much faster by the compiler. The utility
  1061. operates by encoding commonly occurring Amiga keywords. Although ANSI
  1062. is quite specific about the processing of header or include files we
  1063. believe this is a method of increasing the overall compiler
  1064. performance without sacrificing ANSI compliance.
  1065.  
  1066. To use the utility, you need to feed the source file from stdin and
  1067. send the result to stdout. The command line syntax looks like this:
  1068.  
  1069.         lcompact <source >dest
  1070.  
  1071. We have supplied the header files in both compressed and uncompressed
  1072. forms.  There is no difference in the handling of these -- you do not
  1073. have to specify anything special on your command lines or in the
  1074. #include statement. You may also have compressed and uncompressed
  1075. header files within the same directory.
  1076.  
  1077. HEADER FILE ORGANIZATION
  1078.  
  1079. There is now a new subdirectory with the header files called proto.
  1080. This subdirectory contains a number of header files which contain
  1081. function prototypes and the magic material which allow the Amiga
  1082. Library functions to operate. If you are calling an Amiga function,
  1083. you should include the appropriate header file. However, if you want
  1084. to be lazy, you can use the syntax:
  1085.  
  1086.          #include <proto/all.h>
  1087.  
  1088. This will include all the header files although an increase in
  1089. compilation time will be the result. Where the system configuration
  1090. contains expanded memory and everything is being held in memory,
  1091. the increase in compilation time is probably academic.
  1092.  
  1093. Note that these files correspond directly to the .fd files since
  1094. they were constructed from them.
  1095.  
  1096.  
  1097. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1098. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1099. : 9  ::::::::::::::Library Documentation Errors::::::::::::::::::::::
  1100. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1101. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1102.  
  1103. The following modifications were made to the Libraries and Header files
  1104. after the documentation went to print.  These changes are designed to 
  1105. take advantage of the the new ANSI "void *" keyword.  By using "void *"
  1106. instead of "char *", it will no longer be necessary to put casts in
  1107. front of arguments and return values.
  1108.  
  1109. Function      Page          Documentation Correction
  1110. ===============   ====          ========================
  1111.   
  1112. calloc, malloc      L19        change "char *b;" to "void *b;"
  1113. realloc, free
  1114.  
  1115. realloc          L19        return value "nb" should be type "void *"
  1116.  
  1117. getmem, getml      L122          both return a "void *"
  1118.  
  1119. erand48,nrand48,  L44        The variable seed[3] should be type
  1120. jrand48,seed48,            "unsigned short", pseed, should be
  1121. lcong48                type "unsigned short *", and parm[7]
  1122.                 should be type "unsigned short".  This
  1123.                 change is to maintain compatiblity with
  1124.                 System V UNIX.
  1125.  
  1126. LCMFFP.LIB        G16           The lcmffp.lib DOES contain all of the 
  1127.                                 floating point functions that are in the
  1128.                 standard Lattice math library.  
  1129.                   
  1130. The sample call to "emit" on page L51 should read
  1131.     emit(0x4180);
  1132.  
  1133. Also, there is a typo on page v of the Preface to the manual.  The
  1134. reference to the new keyword "_stdards" should read "__stdargs".
  1135. Note, all keywords prefaced with a single underscore should be 
  1136. prefaced with a double underscore.
  1137.  
  1138. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1139. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1140. : 10 :::::::Additional Notes On The Source Level Debugger::::::::::::
  1141. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1142. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1143.  
  1144. IF YOU HAVE ONLY 512K Bytes of MEMORY 
  1145. READ THIS FIRST BEFORE USING CodeProbe!!!!
  1146.  
  1147. CodeProbe requires a large amount of memory to run both itself and an
  1148. application.  Typically you will want to have at least 300K available
  1149. before invoking CPR.  There are several things that you may wish to do
  1150. to minimize the likelyhood of low memory situations.
  1151.  
  1152. 1) Invoke CPR with the "-t cpr.tmp" option.  CPR creates a temporary file 
  1153.    for quick access to symbolic information that it reads from the 
  1154.    application's executable file.  This file can grow to approximately 
  1155.    the same size as the executable file.  By default this file is placed 
  1156.    in "ram:".  The -t option suggested above will cause the file to be 
  1157.    placed in your current directory.  This will be a little slower, however, 
  1158.    it will require less memory.
  1159.    
  1160. 2) Invoke CPR with the "-w" option.  This option will tell CPR to open its
  1161.    windows on the WorkBench Screen rather than on its own custom screen.
  1162.    This will also save memory.
  1163.    
  1164. For example to invoke the ftoc example program under limited memory
  1165. conditions, a user might type:
  1166.  
  1167.    cpr -w -t cpr.tmp ftoc
  1168.  
  1169.  
  1170. Several additions were made to CodeProbe after the manuals went to
  1171. print.
  1172.  
  1173. The File Menu has an additional Item called "Find Current Line".
  1174. This option will automatically cause the source window to find the line
  1175. of program execution.  Both the "Find Current Line" and "Line" options
  1176. will now appear as "Find Current Address" and "Address" when the debugger
  1177. is in Assembler mode.  When prompted for an address, you should enter a
  1178. hexadecimal value.  A '0x' prefix is not required.  The Source window
  1179. will disassemble code beginning at the specified address.
  1180.  
  1181. The Options menu also has an addition item called "Step Into ResLib".
  1182. This option allows the user to decide whether or not to allow CPR to step
  1183. into resident libraries while tracing or running an application with
  1184. Watch Breaks.  This option defaults to "off".  It should never be turned
  1185. on unless you wish to debug your own resident libraries.  Tracing into
  1186. system libraries such as Exec or Intuition can lead to problems.  As
  1187. long as this option remains off, it is safe to run with Watch Breaks on
  1188. while stepping over system resident libraries.
  1189.  
  1190. The mouse can be used to perform a "go line" or "go address" command
  1191. by double clicking the left mouse button with either shift key pressed.
  1192. This compliments the default double click action of "break line" or
  1193. "break address".
  1194.  
  1195. There are several Documentation Errors:
  1196.  
  1197.    There is reference to a -n option on page D130.  No such option has
  1198. been implemented in this release.  If you wish to catch a task started
  1199. from outside of the debugger, you will have to bring up some other 
  1200. program.  You will not of course have to run it.
  1201.  
  1202.    The information about the Symload command on pages D130 and D131 is
  1203. incorrect.  This command can take several forms:
  1204.  
  1205.     symload    proc "process name"
  1206.  
  1207. will find the executable file and the loaded memory segments  associated
  1208. with the specified process if it has CLI structure.  (Note that "symload"
  1209. and "proc" are required keywords in the above example). If the command has
  1210. an executable file name as an additional argument, any debug information
  1211. associated with that file will be loaded instead of looking for the file
  1212. associated with the process.  The address of a process task block can be
  1213. specified in place of the process name.
  1214.  
  1215. Symload can also be given a pointer to a segment list as an argument:
  1216.  
  1217.     symload seg 0x123456 c:executable
  1218.  
  1219. Note that this form requires the keywords "symload" and "seg" as well as
  1220. a the hexadecimal address pointing to the process seglist.  The name
  1221. of an executable file is also required.
  1222.  
  1223. An ARexx interface is supported by CPR.  Macros with a ".cpr" extension
  1224. are recognized.  CPR commands return status codes to ARexx as follows:   
  1225.  
  1226.     0    The debugger command was successful.
  1227.     1    The command was syntactically correct, but failed for some
  1228.         other reason.
  1229.     2       A syntax error occurred.
  1230.     3    The debugger could not allocate memory for the ARexx
  1231.         message.
  1232.  
  1233. In addition to the above error codes, an ARexx macro can receive the 
  1234. output of a debugger command as it would normally appear in the Dialog
  1235. Window by invoking the ARexx command "options results".  The output
  1236. will then be accessable from the variable "result", provided that the
  1237. debugger returned a 0 return code.
  1238.  
  1239. A number of useful macros are provided on disk 4 in the ":examples/debugger"
  1240. directory.  These examples simulate "wack" commands.   For additional 
  1241. information on these macros, read the file CprARexx.DOC on disk 4.  If you
  1242. have any useful ARexx macros you would like to share with other Lattice users
  1243. please upload them to the Lattice Bulletin Board Service or the BIX network.
  1244.  
  1245. We hope that you find release 1.0 of our Source Level Debugger beneficial
  1246. for your development needs. We have incorporated many suggestions from our 
  1247. users into the current release, ARexx support is one example.  We will 
  1248. continue to make enhancements to the product, and we hope that you will
  1249. continue to help shape the future of this tool by offering comments and
  1250. suggestions.  We look forward to hearing from you.  
  1251.  
  1252.  
  1253. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1254. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1255. : 11 ::::::::::::::::::New Keywords in 5.0:::::::::::::::::::::::::::
  1256. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1257. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1258. The new compiler introduces several new keywords:
  1259.  
  1260. The simplest of them is the keyword 'signed'.  It works exactly
  1261. like the unsigned keyword to ensure that a particular variable
  1262. is not unsigned.  While this is the default, the -cu option will
  1263. cause characters to be treated as 'unsigned'.
  1264.   example:
  1265.       signed char c;
  1266.       extern signed int x; 
  1267.  
  1268. The 5.0 compiler provides several keywords to indicate the
  1269. storage class of an object.  With the 4.0 compiler, the only
  1270. way to change the storage class was to use the -b0 or -b1
  1271. flag in conjunction with the -a option on LC2.  These options
  1272. are still available, but the recommended method is to let the
  1273. compiler default to near addressing (-b1) and then use the
  1274. keywords where necessary.  Unlike MS-DOS based compilers, these
  1275. keywords do not affect the size of an object, but instead
  1276. indicate the storage class.  In that vein, you MUST place the
  1277. keyword as close to the data item as possible:
  1278.  
  1279.     extern int __near x;      /* addressed as a4 relative */
  1280.     extern long __far y;      /* addressed with a 32 bit absolute */
  1281.     extern struct Custom far custom;  /* "" */
  1282.     extern char * near y;
  1283.     static int far y;         /* Place in the far section */
  1284. Note that you can not use the storage keyword except immediately
  1285. before the target object.
  1286.     extern far int wrong;  /* <<< Illegal */
  1287.     static near char *nogood; /* <<< Not allowed */
  1288.  
  1289. The most important of these new storage class keywords is the
  1290. chip (or __chip) keyword.
  1291.     static struct Image chip myimage = {  ... };
  1292.     extern struct Image chip pict;
  1293. This will cause the compiler to place the target object into memory
  1294. addressable by the Amiga custom chips.
  1295.  
  1296. It is also important to note that that storage class keywords allow
  1297. two versions: __far  and far.  The version with the double underscores
  1298. is intended to allow for an ANSI conforming program while we offer
  1299. the non-ANSI version for more readable code and some compatibility
  1300. with MS-DOS based products.
  1301.  
  1302. The 5.0 compiler also provides a number of keywords that may be
  1303. applied to functions to permit special calling conventions.
  1304. Of importance are the __regargs and __stdargs keywords which indicate
  1305. that the compiler is to use an altered calling convention.  By
  1306. default, the compiler will use __regargs for everything.  However,
  1307. if you use the -rr option of LC1, the compiler will use a __regargs
  1308. convention in which the first two data items and first two
  1309. pointer items are passed in d0/d1 and a0/a1 respectively.  The keywords
  1310. allow you to override the default.  For example:
  1311.    extern int __stdargs myprintf();
  1312.    long __regargs foo(int i)   { ... }
  1313.    __stdargs void bar();
  1314. These keywords may appear anywhere before the identifier to which they
  1315. are applied.
  1316.  
  1317. With the 4.0 compiler, it was necessary to use the -y option on LC2
  1318. in order to load up the address of the global data base at entry to
  1319. a function.  This however applied to all functions in a module.
  1320. To cause it to be loaded for a single function, you can use the
  1321. keyword __saveds as in:
  1322.     int __saveds myentry() { .... }
  1323. Note that __saveds only has meaning when applied to the actual
  1324. definition of the function.  External functions with the __saveds
  1325. keyword simply ignore the keyword.
  1326.  
  1327. Like the __saveds keyword, the __interrupt keyword is applied to
  1328. a function to indicate that this function may be called from an
  1329. interrupt routine.  Although at this release it currently does not
  1330. affect the code generated for the function, it is provided for
  1331. potential variations in code necessary to support interrupts on
  1332. non-Amiga compilers.
  1333.  
  1334. Providing the most control over register passing, the __asm keyword
  1335. allows you to specify exactly which registers parameters are to
  1336. be passed in.  It can be used for both function definitions and
  1337. function declarations:
  1338.   extern int __asm mymax( register __d0 int i, register __d1 int j);
  1339.   int __asm myfun( i,p )
  1340.    register __d0 int i;
  1341.    register __a1 char *p;
  1342. In order for the register specifier sequence to be used, you must
  1343. have the __asm keyword specified on the function.  If you do use
  1344. the __asm keyword, you MUST specify a register for all parameters
  1345. and not reuse the same register for any two parameters.  If you
  1346. need to pass some parameters on the stack then you should consider
  1347. using the __regargs keyword instead.
  1348.  
  1349. In order to permit the most flexibility in register passing, the
  1350. compiler does not limit what registers may be passed.  However this
  1351. can lead to some situations which would make it impossible to
  1352. generate code that works in the presence of aliased variables.
  1353. To ensure that such situations are not presented, you should avoid
  1354. utilizing registers that would normally assigned as register variables
  1355. and instead stick to the registers:
  1356.     __d0  __d1  __d2 __d3  __a0 __a1 __a6
  1357. The best advice is to be careful when using this feature and if you
  1358. are uncomfortable with it, utilize the -rr option of LC1 (or
  1359. __regargs) in which the compiler will pick the best registers.
  1360.  
  1361. The keywords __asm, __stdargs, and __regargs are mutually exclusive.
  1362.  
  1363. *** Please note, the double underscores ***
  1364.   
  1365. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1366. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1367. : 12 :::::::::::::::::::Library Descriptions:::::::::::::::::::::::::
  1368. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1369. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1370. cback.o
  1371.          Startup routine to detach process from CLI and run in background.
  1372.  
  1373. catchres.o
  1374.          Startup routine to catch software exceptions in resident programs.
  1375.  
  1376. lcs.lib 
  1377.          Lattice C Library for use with 16-bit integers.
  1378.  
  1379. catch.o  
  1380.          Startup routine to catch software exceptions.
  1381.  
  1382. lcms.lib 
  1383.          Lattice Standard IEEE Math Library for use with 16-bit integers.
  1384.  
  1385. lcm881.lib
  1386.          Lattice 68881 Coprocessor Math Library.
  1387.  
  1388. c.o      
  1389.          Standard Lattice Startup routine.
  1390.  
  1391. lcnb.lib
  1392.          Lattice C Library for use with no base-relative data addressing.
  1393.  
  1394. catchresnr.o                
  1395.          Startup - Catch Exceptions, Resident, No Requesters on exception.
  1396.  
  1397. lcmffp.lib                 
  1398.          Lattice Motorola Fast Floating Point Math Library.
  1399.  
  1400. lcmieee.lib                
  1401.          Lattice IEEE Math Library for use with Commodore Resident Library.
  1402.  
  1403. lcsr.lib                   
  1404.          Lattice C Library for use with 16-bit integers and Registerized Parameters.
  1405.  
  1406. lcr.lib                    
  1407.          Lattice C Library for use with Registerized Parameters.
  1408.  
  1409. lcmr.lib                   
  1410.          Lattice IEEE Math Library for use with Registerized Parameters.
  1411.  
  1412. lc.lib                     
  1413.          Lattice Standard C Library.
  1414.  
  1415. cres.o                      
  1416.          Startup routine for Resident Programs.
  1417.  
  1418. lcm.lib                    
  1419.          Lattice Standard IEEE Math Library.
  1420.  
  1421. lcsnb.lib                  
  1422.          Lattice C Library for 16-bit integers and no base-relative 
  1423.          addressing.
  1424.  
  1425. ddebug.lib                  
  1426.          Commodore debug library for use with Parallel Port.
  1427.  
  1428. debug.lib                   
  1429.          Commodore debug library for use with Serial Port.
  1430.  
  1431. amiga.lib
  1432.          Library of linkage routines to Amiga Resident Libraries.
  1433.  
  1434.  
  1435. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1436. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1437. : 13 ::::::::::::::::::Binary Patch Program::::::::::::::::::::::::::
  1438. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1439. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1440.  
  1441. Lattice traditionally releases software "patches" to correct problems
  1442. which are found. Included on Disk 3 is a binary patch utility named 
  1443. "PATCH" which may be used to apply future patches (provided by Lattice) 
  1444. to the compiler and tools. The calling sequence is as follows:
  1445.  
  1446. PATCH oldfile [-ooutput -ppatchfile]
  1447.  
  1448.     where:
  1449.         oldfile          is the old file to be patched.
  1450.         output           is the output file, default oldfile.new
  1451.         patchfile        is the patchfile supplied by Lattice, Inc.
  1452.  
  1453.   
  1454. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1455. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1456. : 14 ::::::::::::::::::::::    68881 Notes  :::::::::::::::::::::::::
  1457. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1458. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1459.  
  1460. M68881
  1461.  
  1462. The code generated for the 68881 (-f8 option) runs differently than
  1463. than standard code in the following ways:
  1464.  
  1465.     1) Converting doubles to longs does not truncate the decimal
  1466.            places as with standard code. Instead it rounds off.
  1467.  
  1468.         2) The recommended procedure for calling trig functions is to
  1469.        use the header file M68881.h. This code will run much faster
  1470.        than the routines in the lcm881.lib library.
  1471.        
  1472.         3) The trig functions do not return the proper value if a 
  1473.            error occurs, ie acos(1.1).
  1474.            
  1475.         4) There is a known bug in placing a constant into a single
  1476.        precision float in modules compiled with -f8.
  1477.  
  1478.  
  1479. :::::::::::::::::::END OF FILE:::::::::::::::::::::::::::::::::::::::::::